package com.woniuxy.controller;

import com.woniuxy.entity.dto.PickupOrderDTO;
import com.woniuxy.entity.dto.SignOrderDTO;
import com.woniuxy.service.SignOrderService;
import com.woniuxy.util.MinioUtils;
import com.woniuxy.util.PageData;
import com.woniuxy.util.ResponseData;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/signOrder")
public class SignOrderController {

    @Resource
    private SignOrderService signOrderService;
    @Resource
    private MinioUtils minioUtils;

    @PostMapping("/querySignOrder")
    public ResponseData<?> querySignOrder(@RequestBody PageData<SignOrderDTO> pageData){
        return  signOrderService.querySignOrder(pageData);
    }

    @PostMapping( "/handleSign")  //签收  带订单id
    public ResponseData<?> handleSign(@RequestBody SignOrderDTO signOrderDTO) {
        return signOrderService.handleSign(signOrderDTO);
    }

    @GetMapping("/querySignDetail/{orderId}")
    public ResponseData<?> querySignDetail(@PathVariable("orderId") String orderId){
        return  signOrderService.querySignOrderDetails(orderId);
    }
    /**
     * 头像上传解决
     * 怎么接收（图片）文件类型数据
     * MultipartFile:接收文件类型数据
     */
    @PostMapping("/imgLoad")
    public ResponseData<?> uploadImg(MultipartFile file){
        try {
            return minioUtils.uploadFile(file, "img");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("上传失败");
        }
    }

//    @PostMapping( "/updateImg")  // 修改数据库图片
//    public ResponseData<?> updateImg(@RequestBody SignOrderDTO signOrderDTO) {
//        return signOrderService.updateImg(signOrderDTO);
//    }







}
